<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="css/aui.css">
    <script type="text/javascript" src="js/jquery-3.3.1.min.js"></script>
    <script type="text/javascript" src="js/init.js"></script>
    <title>提现</title>
</head>
<body>
<header>
    <a href="javascript:history.back(-1)" class="f1 head-back"></a>
    <div class="f8">提现</div>
    <div class="f1"></div>
</header>
<section class="bg-gray">
    <ul class="pad-3 color-gray">
        <li class="mar-b-3">
            <b>
                <span class="color-red">*</span>
                我的钱包
            </b>
            <p id="mymoney" class="pad-1-2 border-gray border-radius-1 mar-t-1 bg-gray-l">以太坊（ETH）:</p>
        </li>
        <li class="mar-b-3 re">
            <b>
                <span class="color-red">*</span>
                提现账户
            </b>
            <p id="txway" class="pad-1-2 border-gray border-radius-1 mar-t-1 bg-white">
                <i>以太坊（ETH）</i>
                <span class="arrow3 fr mar-t-2"></span>
            </p>
            <ul id="txlist" class="ab col-10 bg-white border-radius-1 pad-l-r-3 none">
                <li class="flex pad-t-b-2" data-id="1">
                    <span class="f1">以太坊（ETH）</span>
                    <span class="radio active"></span>
                </li>
                <li class="flex pad-t-b-2" data-id="2">
                    <span class="f1">以太经典（ETC）</span>
                    <span class="radio"></span>
                </li>
            </ul>
        </li>
        <li class="mar-b-3">
            <b>
                <span class="color-red">*</span>
                提现金额
            </b>
            <input id="money" class="col-10 pad-1-2 bg-white border-radius-1 border-gray mar-t-1" type="number" placeholder="请输入提现金额">
            <p class="color-blue font25">提现最小金额<span id="min_money">0.00</span>，提现最大金额<span id="max_money">0.00</span>，提现倍数0，提现手续费2%</p>
        </li>
        <li class="mar-b-3">
            <b>
                <span class="color-red">*</span>
                说明
            </b>
            <textarea id="remark" class="col-10 bg-white border-radius-1 border-gray pad-1-2 font3 mar-t-1" rows="4" placeholder="请输入说明"></textarea>
        </li>
        <li class="mar-b-3">
            <b>
                <span class="color-red">*</span>
                短信验证码
            </b>
            <input id="code" class="col-10 pad-1-2 bg-white border-radius-1 border-gray mar-t-1" type="number" placeholder="请输入短信验证码" onfocus="inputFocus()">
        </li>
        <li class="mar-b-3">
            <b>
                <span class="color-red">*</span>
                二级密码
            </b>
            <input id="password_2" class="col-10 pad-1-2 bg-white border-radius-1 border-gray mar-t-1" type="password" placeholder="请输入二级密码" onfocus="inputFocus()">
        </li>

        <li class="color-white center pad-t-2">
            <span class="pad-2-3 border-radius-1 bg-blue" onclick="tijiao()">确定</span>
            <a href="tiixanRecord.html" class="pad-2-3 border-radius-1 bg-blue-l color-white">查看</a>
            <span class="pad-2-3 border-radius-1 bg-yellow" onclick="getyzm()">发送验证码</span>
        </li>
    </ul>
</section>

<script src="js/foot.js"></script>
<script>
    //可提现最小 最大金额
    var params = window.location.search.substr(1).split('&');
    var min = params[0].split('=')[1];
    var max = params[1].split('=')[1];
    $("#min_money").text(min);
    $("#max_money").text(max);

    var type = 1;
    // 获取自己的eth etc 总数
    var allmoney;
    var data2;
    new AjaxRequest({
        type: 'post',
        dataType: 'json',
        url: hostUrl + 'index/Withdraw/getmoneys',
        data: data2,
        callback: res => {
            if(res.status == 1){
                allmoney = res.data;
                if(type == 1){
                    $("#mymoney").text('以太坊（ETH）：'+res.data.ethmoney);
                }
                if(type == 2){
                    $("#mymoney").text('以太经典（ETC）：'+res.data.etcmoney);
                }
            }
        }
    });

    $("#txway").click(function () {
        $("#txlist").show();
    });
    $("#txlist li").click(function () {
        $("#txlist li .radio").removeClass('active');
        $(this).children('.radio').addClass('active');
        var text = $(this).children(".f1").text();
        $("#txway i").text(text);
        $("#txlist").hide();
        type = $(this).attr('data-id');
        if(type == 1){
            $("#mymoney").text('以太坊（ETH）：'+allmoney.ethmoney);
        }
        if(type == 2){
            $("#mymoney").text('以太经典（ETC）：'+allmoney.etcmoney);
        }
    });

    function getyzm() {
        var data;
        new AjaxRequest({
            type: 'post',
            dataType: 'json',
            url: hostUrl + 'index/Withdraw/sendmsg',
            data: data,
            isShowLoader: true,
            callback: res => {
                toast(res.msg);
                if(res.status == 1){

                }
            }
        });
    }

    function tijiao() {
        var money = $("#money").val();
        var remark = $("#remark").val();
        var code = $("#code").val();
        var password_2 = $("#password_2").val();
        if(!money ||!remark ||!code ||!password_2){
            toast('请填写完整信息');
            return;
        }
        var data = {};
        data.userid = localStorage.user_id;
        data.token = localStorage.token;
        data.extract_money = money;
        data.coin_type = type;
        data.password_2 = password_2;
        data.code = code;
        data.remark = remark;
        new AjaxRequest({
            type: 'post',
            dataType: 'json',
            url: hostUrl + 'index/Withdraw/extract',
            data: data,
            isShowLoader: true,
            callback: res => {
                toast(res.msg);
                if(res.status == 1){
                    setTimeout(function () {
                        location.href = 'tiixanRecord.html';
                    },2000)
                }
            }
        });
    }

    /*function inputFocus(e) {
        var num = document.getElementById('code');
        var pwd = document.getElementById('password_2');

        let u = navigator.userAgent, app = navigator.appVersion;
        let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1;
        if(isAndroid){
            setTimeout(function() {
                num.scrollIntoViewIfNeeded();
                num.scrollIntoView();

                pwd.scrollIntoViewIfNeeded();
                pwd.scrollIntoView();

            }, 500);
        }
    }*/

</script>
</body>
</html>